package com.wuji.blog.utils;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @作者 wangj
 * @日期 2022/1/19 15:25
 * @描述 通用返回result
 **/
@Data
@AllArgsConstructor
public class Result {

    private boolean success;
    private int code;
    private String msg;
    private Object data;

    public static Result success(Object data){
        return new Result(true,200,"success",data);
    }
    public static Result success(){
        return new Result(true,200,"success",null);
    }

    public static Result fail(int code, String msg){
        return new Result(false,code,msg,null);
    }
    public static Result fail(ErrorCode errorCode){
        return new Result(false, errorCode.getCode(), errorCode.getMsg(),null);
    }
}
